package com.ysx.oa.hl.controller;

import com.ysx.oa.hl.service.CalculatorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/cal")
public class CalculatorController {

    @Autowired
    private CalculatorService service;

    @RequestMapping(value="/sum.do",method = RequestMethod.GET)
    public Map<String,Object> sum(Integer x,Integer y){
        Map<String,Object> map = new HashMap();
        int sum =0;
        try{
            sum = service.sum(x,y);
        }catch (Exception exception){
            System.out.println(exception);
        }
        map.put("code",200);
        map.put("message","success");
        map.put("data",sum);
        return map;
    }
}
